<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test01</title>
</head>
<body>
<script type="text/javascript">
    // function Person(name, age) {
    //     this.name = name;
    //     this.age = age;
    // }
    //
    // Person.prototype.sayName = function () {
    //     console.log(this.name);
    // };
    //
    // function Student(name, age, school) {
    //     this.name = name;
    //     this.age = age;
    //     this.school = school;
    // }
    //
    // Student.prototype = Person.prototype;

    class Person {
        static foo = 'bar';

        constructor(name, age) {
            this.name = name;
            this.age = age;
            // this.sayName = this.sayName.bind(this);
        }

        // sayName() {
        //     console.log(this.name);
        // }

        sayName = () => console.log(this.name);

        static sayFoo() {
            // console.log(Person.foo);
            console.log(this.foo);
        }
    }

    class Student extends Person {
        constructor(name, age, school) {
            super(name, age);
            this.school = school;
        }
    }

    let stu01 = new Student("zhangsan", 18, "abc school");
    let stu02 = new Student("lisi", 20, "efg school");

    stu01.sayName();
    stu02.sayName();

    // console.log(Person.foo);
    // console.log(Student.foo);
    //
    // Student.sayFoo();

    let p01 = new Person("zhangsan", 18);

    console.dir(Person);
    console.dir(p01);

    console.log(p01.__proto__ == Person.prototype);
    console.log(stu01.__proto__ == Student.prototype);

    console.log(Person.__proto__ == Function.prototype);

    console.log(Object.getPrototypeOf(p01) == Person.prototype);

</script>
</body>
</html>